import pygame
from pygame.sprite import Sprite

class Alien(Sprite):
    def __init__(self,ai_settings,screen,my_color):
        super(Alien,self).__init__()
        self.ai_settings = ai_settings
        self.screen = screen
        match my_color%3:
            case 1:
                self.image = pygame.image.load("D:\\bili_download\\Alien_Invasion\\imagessss\\alien1.bmp")
            case 2:
                self.image = pygame.image.load("D:\\bili_download\\Alien_Invasion\\imagessss\\alien2.gif")
            case 0:
                self.image = pygame.image.load("D:\\bili_download\\Alien_Invasion\\imagessss\\alien3.bmp")

        self.rect = self.image.get_rect()
        # Initialise the alien
        self.rect.x = self.rect.width
        self.rect.y = self.rect.height

        # Exact position
        self.x = float(self.rect.x)

    def blitme(self):
        self.screen.blit(self.image,self.rect)

    def update(self):
        self.x += self.ai_settings.alien_speed*self.ai_settings.direction
        self.rect.x = self.x

    def check_edge(self):
        screen_rect = self.screen.get_rect()
        if self.rect.right >= screen_rect.right:
            return True
        elif self.rect.left <= 0:
            return True
